<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"      
      xmlns:p="http://primefaces.org/ui">

    <ui:composition template="/template.xhtml">
        <ui:define name="title">
            <h:outputText value="#{bundle.ListWebserviceTitle_relatorioPorEstacao}"></h:outputText>
        </ui:define>
        <ui:define name="body">

            <h:panelGroup id="messagePanel" styleClass="ajustaListaMensagemErro"  layout="block" >
                <h:messages errorStyle="color: red" infoStyle="color: green" layout="list" />
            </h:panelGroup>

            <p:panel header="#{bundle.ListWebserviceTitle_criterios}"> 

                <h:panelGrid columns="2" style="margin-bottom:10px" cellpadding="5">

                    <h:outputLabel value="#{bundle.ListWebserviceTitle_estacao}" for="estacao" />
                    <p:selectOneMenu value="#{webServiceController.estacao}" filter="true" filterMatchMode="contains" id ="estacao" >
                        <f:selectItems value="#{webServiceController.estacoesSelectOne}"/>
                        <p:ajax listener="#{webServiceController.alteraDadosListaEstacao}" update="panelCabecalho, tblPorEstacao" />
                    </p:selectOneMenu>                     
                </h:panelGrid>
            </p:panel>

            <p:panel header="Detalhes da Esta&ccedil;&atilde;o: " id="panelCabecalho" >
                <h:panelGrid columns="2" style="margin-bottom:5px" cellpadding="5">     
                    <h:outputLabel value="Nome: " style="font-weight: bold;" for="estNome" />
                    <h:outputText value="#{webServiceController.estacao.estNome}" id="estNome" />
                    <h:outputLabel value="Codigo FLU: " style="font-weight: bold;" for="estFlu" />
                    <h:outputText value="#{webServiceController.estacao.estCodigoAdicional}" id="estFlu" />
                    <h:outputLabel value="Codigo PLU: " style="font-weight: bold;" for="estPlu" />
                    <h:outputText value="#{webServiceController.estacao.estAneelPlu}" id="estPlu" />
                </h:panelGrid>
                <hr /><br />

                <div align="center">

                    <p:dataTable id="tblPorEstacao" value="#{webServiceController.listaDadosEstacao}" var="item"  paginator="true" rows="#{bundle.rows}" 
                                 pageLinks="5" widgetVar="porEstacaoTable" currentPageReportTemplate="#{bundle.currentPageReportTemplate}"  
                                 paginatorTemplate="#{bundle.paginatorTemplate}" rowsPerPageTemplate="#{bundle.rowsPerPageTemplate}"  
                                 paginatorPosition="#{bundle.paginatorPosition}" rowKey="#{item.estCodigo}" emptyMessage="#{bundle.ListEstacaoEmpty}" 
                                 filteredValue="#{webServiceController.listaDadosEstacao}" styleClass="mystyle" style="width: 80%">

                        <p:column exportable="true" styleClass="column100px" style="text-align: center;" sortBy="#{filterSearchController.customFormatDate1(item.horDataHora)}" 
                                  filterBy="#{filterSearchController.customFormatDate(item.horDataHora)}" filterMatchMode="contains">
                            <f:facet name="header">
                                <h:outputText styleClass="cabecalhoNegrito" value="#{bundle.ListWebserviceTitle_dtHoraDaMedicao}"/>
                            </f:facet>
                            <h:outputText value="#{item.horDataHora}" >
                                <f:convertDateTime  pattern="#{bundle.patternAppDataHora}" timeZone="#{filterSearchController.timeZone}"/>
                            </h:outputText>
                        </p:column>  

                        <p:column exportable="true" styleClass="column100px" style="text-align: center;" sortBy="#{filterSearchController.customFormatDate1(item.horDataAmostra)}" 
                                  filterBy="#{filterSearchController.customFormatDate(item.horDataAmostra)}" filterMatchMode="contains">
                            <f:facet name="header">
                                <h:outputText styleClass="cabecalhoNegrito" value="#{bundle.ListWebserviceTitle_dtHoraChegadaANA}"/>
                            </f:facet>
                            <h:outputText value="#{item.horDataAmostra}" >
                                <f:convertDateTime  pattern="#{bundle.patternAppDataHora}" timeZone="#{filterSearchController.timeZone}"/>
                            </h:outputText>
                        </p:column> 

                        <p:column exportable="true" styleClass="firstColumn" filterMatchMode="contains">
                            <f:facet name="header">
                                <h:outputText styleClass="cabecalhoNegrito" value="Chuva: "/>
                            </f:facet> 
                            <h:outputText value="#{item.horChuva}" >
                                <f:convertNumber locale="#{bundle.localeApp}" maxFractionDigits="#{bundle.maxFractionDigits}" minFractionDigits="#{bundle.minFractionDigits}"/>
                            </h:outputText>
                        </p:column>       

                        <p:column exportable="true" styleClass="firstColumn" filterMatchMode="contains">
                            <f:facet name="header">
                                <h:outputText styleClass="cabecalhoNegrito" value="Nivel"/>
                            </f:facet> 
                            <h:outputText value="#{item.horNivel}" >
                                <f:convertNumber locale="#{bundle.localeApp}" maxFractionDigits="#{bundle.maxFractionDigits}" minFractionDigits="#{bundle.minFractionDigits}"/>
                            </h:outputText>
                        </p:column>

                        <p:column exportable="true" styleClass="firstColumn" filterMatchMode="contains">
                            <f:facet name="header">
                                <h:outputText styleClass="cabecalhoNegrito" value="Vazao"/>
                            </f:facet> 
                            <h:outputText value="#{item.horVazao}" >
                                <f:convertNumber locale="#{bundle.localeApp}" maxFractionDigits="#{bundle.maxFractionDigits}" minFractionDigits="#{bundle.minFractionDigits}"/>
                            </h:outputText>
                        </p:column>

                        <f:facet name="footer">
                            <p:commandButton id="excelExportAll" ajax="false" value="#{bundle.excelExportAll}" icon="#{bundle.icone_script}">
                                <p:dataExporter  type="xls" target="tblPorEstacao" fileName="#{bundle.excelExportAllFileName_estacoes}" postProcessor="#{filterSearchController.postProcessorXLS}"/>
                            </p:commandButton>
                        </f:facet>

                    </p:dataTable>                  
                </div>
            </p:panel>
        </ui:define>
    </ui:composition>
</html>
